from django.contrib import admin
from django.utils.safestring import mark_safe

from .models import *


class ItemListAdmin(admin.ModelAdmin):
    search_fields = ('title', 'shopNick')
    fields = ('id', '标题')
    list_filter = ('postal',)
    list_display = (
        'id',
        'title',
        'price',
        'postal',
        'shopNick',
        'payNum',
        'count',
        'image_data'
    )

    def image_data(self, obj):
        return mark_safe(u'<img src="{}" width="100px" />'.format(obj.image))

    image_data.short_description = u'商品图片'


# admin.site.register(ItemList)
admin.site.register(ItemList, ItemListAdmin)
admin.site.register(Pay_log)

# Register your models here.
